/**
 * 系统的面包屑导航配置
 * @author: minzhang
 * @update: 2016-03-07
 */

import React, { PropTypes } from 'react';
import { Breadcrumb, Link } from 'antd';

const CommonBreadcrumb = ({
	location,
}) => {
    
	const config = {
		'/': [{
			text: '收银管理',
			path: '/',
		}, {
			text: '开单',
			path: '',
		}],
		'/reservation': [{
			text: '收银管理',
			path: '/',
		}, {
			text: '预约',
			path: '',
		}],
		'/order': [{
			text: '收银管理',
			path: '/',
		}, {
			text: '订单',
			path: '',
		}],
		'/store-info': [{
			text: '门店设置',
			path: '/store-info',
		}, {
			text: '门店信息',
			path: '',
		}],
		'/rooms-manage': [{
			text: '门店设置',
			path: '/store-info',
		}, {
			text: '包间管理',
			path: '',
		}],
		'/project-manage': [{
			text: '门店设置',
			path: '/store-info',
		}, {
			text: '项目管理',
			path: '',
		}],
		'/product-manage': [{
			text: '门店设置',
			path: '/store-info',
		}, {
			text: '产品管理',
			path: '',
		}],
		'/recommend-manage': [{
			text: '门店设置',
			path: '/store-info',
		}, {
			text: '推荐提成管理',
			path: '',
		}],
		'/tech-manage': [{
			text: '门店设置',
			path: '/store-info',
		}, {
			text: '技师管理',
			path: '',
		}],
		'/member-card': [{
			text: '门店设置',
			path: '/store-info',
		}, {
			text: '会员卡套餐',
			path: '',
		}],
		'/times-card': [{
			text: '门店设置',
			path: '/store-info',
		}, {
			text: '次卡套餐',
			path: '',
		}],
		'/person-manage': [{
			text: '门店设置',
			path: '/store-info',
		}, {
			text: '人员管理',
			path: '',
		}],
		'/general-setting': [{
			text: '门店设置',
			path: '/store-info',
		}, {
			text: '参数设置',
			path: '',
		}],
	};
	
	const items = config[location.pathname].map(
		(value, index) => {
//			const flag = index === 0 || index === (config[location.pathname].length - 1);
			const props = {
				key: index,
			}
			if(value.path) {
				props.href = `#${value.path}`;
			}
			return <Breadcrumb.Item {...props} >{value.text}</Breadcrumb.Item>
		}
	);
	
  return (
		<Breadcrumb style={{ margin: '12px 16px' }} >
			{items}
		</Breadcrumb>
  );
};

CommonBreadcrumb.propTypes = {
  location: PropTypes.object,
};

export default CommonBreadcrumb;